from .type_system import LanguageTypeMapper
from .field_processor import FieldProcessor
from .meta_processor import MetaInfoProcessor, MetaInfoContainer
from .framework_meta import VueMetaInfo, SpringBootMetaInfo
from .sql_table_info import TableInfoSQL, TableInfoConfig

def create_meta_info(sql_info: TableInfoSQL, config: TableInfoConfig):
    """创建元数据实例的工厂函数"""
    # 创建基础组件
    type_mapper = LanguageTypeMapper()
    field_processor = FieldProcessor()
    processor = MetaInfoProcessor(type_mapper, field_processor)

    # 创建元数据容器
    container = MetaInfoContainer(sql_info, config, processor)

    # 根据目标语言创建对应的元数据处理器
    if hasattr(config, 'target_language') and config.target_language == 'typescript':
        return VueMetaInfo(container)
    else:
        return SpringBootMetaInfo(container, config.java_package_name)